import React from "react";
import { Text, TouchableOpacity, Platform } from "react-native";
import _ from 'lodash';
import styles from "./styles";

export default ({ value, placeholder, fn, onPress = v => v }) => {
  if (Platform.OS === 'ios') {
    return (
      <TouchableOpacity style={{ justifyContent: 'center', flex: 1}} onPress={onPress}>
        <Text style={[{ color: value ? '#333' : '#ccc', textAlign: 'right' }]}>
          {value ? (_.isFunction(fn) ? fn(value) : value) : placeholder}
        </Text>
      </TouchableOpacity>
    );
  }
  return (
    <Text style={[styles.input, { color: value ? '#333' : '#ccc' }]}>
      {value ? (_.isFunction(fn) ? fn(value) : value) : placeholder}
    </Text>
  )
}